home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / macify13.shr / macify.hqx / Source / Macify Code / macify.c < prev    next >
Text File  |  1991-03-15  |  2KB  |  52 lines

  1. /*************************************************************************
  2.  **                                                                        **
  3.  **                                    TM                                    **
  4.  **                              Macify    1.0                                **
  5.  **                                                                        **
  6.  **                    By Donald Burr  --  Copyright 1991                    **
  7.  **                                                                        **
  8.  **                      Released to the Public Domain                        **
  9.  **                                                                        **
  10.  ** Version History                                                        **
  11.  **                                                                        **
  12.  ** Date        Version        Comments                                    **
  13.  ** ----        -------        --------                                    **
  14.  ** 15-Mar-91    1.0            Initial release.                            **
  15.  **                            Fixed file closure bug; it now properly        **
  16.  **                            closes files when done with them.            **
  17.  **                                                                        **
  18.  *************************************************************************/
  19.  
  20. #include     <stdio.h>        /* Standard I/O functions */
  21. #include    <string.h>        /* BSD uses strings.h */
  22. #include    "macify.h"        /* defines for MACIFY */
  23.  
  24. void macify(thing_to_do, in, out)            /* main Macify function */
  25. int        thing_to_do;        /* what to do, what to do */
  26. char    *in, *out;
  27. {
  28.     char    the_input, the_output;    /* input gathered from program */
  29.     char    do_the_conversion();    /* this function does the stuff */
  30.     FILE    *infile, *outfile, *fopen();
  31.     int        fclose();
  32.     
  33.     /* Assign filenames */
  34.  
  35.         infile = fopen(in, "r");    /* open the file specified */
  36.         outfile = fopen(out, "w");    /* open for output */
  37.  
  38.     /* Get input char-by-char */
  39.  
  40.     while ((the_input = fgetc(infile)) != EOF)  {
  41.                     /* while we've still got stuff */
  42.         the_output = do_the_conversion(the_input, thing_to_do);
  43.         fputc(the_output, outfile);
  44.                         /* Do the conversion */
  45.         }
  46.     putchar(BELL);        /* Beep to let know of completion */
  47.     printf("\nMACIFY is complete.  %s has been converted to %s.\n",
  48.             in, out);
  49.     fclose(infile);
  50.     fclose(outfile);
  51. }
  52.